/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Scanner;

/**
 *
 * @author JE
 */
public class FileReaderUtil {
    public static model.Checker[][] getBoardFromFile(String fileName){
        model.Checker[][] bd=new model.Checker[8][8];
        String text;
        String[] parsedText;
        int i=0;
        Scanner scanner=null;
        try {
            scanner = new Scanner(new FileInputStream(fileName));
            int checkerIndex;
            while (scanner.hasNextLine()){
                text=scanner.nextLine();
                parsedText=text.split(" ");
                for(int j=0;j<8;j++){
                    checkerIndex=Integer.parseInt(parsedText[j]);
                    bd[i][j]=model.Checker.values()[checkerIndex];
                }
                i++;
            }
        }catch(IOException e){
            
        }
        finally{
            if(scanner!=null)
                scanner.close();
        }
        
        return bd;
    }
    
}
